def finnaDeili(x, y):
	if x < y:
		meh = y
		y = x
		x = meh
	if x == y:
		return x
	afgangur = 7788
	while afgangur:
		if x > y:
			afgangur = x%y
			x = afgangur
		elif y > x:
			afgangur = y%x
			y = afgangur
	if x == 0:
		return y
	return x
	
tala1 = input()
tala2 = input()
print(finnaDeili(int(tala1), int(tala2)))
